package com.wutuo.roster.provider.dao;



import com.wutuo.roster.provider.domain.ChildApply;

import static org.apache.ibatis.jdbc.SqlBuilder.*;

/**
 * 孩子申请 Dao 层
 *
 * @author lvh
 * @version 1.0
 */

public class BaseChildApplySqlProvider implements java.io.Serializable {


    public String insertSelective(ChildApply record) {
        BEGIN();
        INSERT_INTO("child_apply");
        insertKey(record);
        return SQL();
    }

    public void insertKey(ChildApply record) {

        if (record.getUserId() != null) {
            VALUES("user_id", "#{userId,jdbcType=VARCHAR}");
        }
        if (record.getCmInstitutionId() != null) {
            VALUES("cm_institution_id", "#{cmInstitutionId,jdbcType=VARCHAR}");
        }
        if (record.getCreateBy() != null) {
            VALUES("create_by", "#{createBy,jdbcType=VARCHAR}");
        }
        if (record.getCreateDate() != null) {
            VALUES("create_date", "#{createDate,jdbcType=VARCHAR}");
        }
        if (record.getUpdateBy() != null) {
            VALUES("update_by", "#{updateBy,jdbcType=VARCHAR}");
        }
        if (record.getUpdateDate() != null) {
            VALUES("update_date", "#{updateDate,jdbcType=VARCHAR}");
        }
        if (record.getRemarks() != null) {
            VALUES("remarks", "#{remarks,jdbcType=VARCHAR}");
        }
        if (record.getDelFlag() != null) {
            VALUES("del_flag", "#{delFlag,jdbcType=VARCHAR}");
        }
        if (record.getName() != null) {
            VALUES("name", "#{name,jdbcType=VARCHAR}");
        }
        if (record.getPhoto() != null) {
            VALUES("photo", "#{photo,jdbcType=VARCHAR}");
        }
        if (record.getSex() != null) {
            VALUES("sex", "#{sex,jdbcType=VARCHAR}");
        }
        if (record.getTgType() != null) {
            VALUES("tg_type", "#{tgType,jdbcType=VARCHAR}");
        }
        if (record.getGrade() != null) {
            VALUES("grade", "#{grade,jdbcType=VARCHAR}");
        }
        if (record.getYear() != null) {
            VALUES("year", "#{year,jdbcType=VARCHAR}");
        }
        if (record.getState() != null) {
            VALUES("state", "#{state,jdbcType=VARCHAR}");
        }
    }

    public String updateByPrimaryKeySelective(ChildApply record) {
        BEGIN();
        UPDATE("child_apply");
        updateKey(record);
        WHERE("id = #{id,jdbcType=BIGINT}");
        return SQL();
    }

    public void updateKey(ChildApply record) {
        if (record.getId() != null) {
            SET("id = #{id,jdbcType=VARCHAR}");
        }
        if (record.getUserId() != null) {
            SET("user_id = #{userId,jdbcType=VARCHAR}");
        }
        if (record.getCmInstitutionId() != null) {
            SET("cm_institution_id = #{cmInstitutionId,jdbcType=VARCHAR}");
        }
        if (record.getCreateBy() != null) {
            SET("create_by = #{createBy,jdbcType=VARCHAR}");
        }
        if (record.getCreateDate() != null) {
            SET("create_date = #{createDate,jdbcType=VARCHAR}");
        }
        if (record.getUpdateBy() != null) {
            SET("update_by = #{updateBy,jdbcType=VARCHAR}");
        }
        if (record.getUpdateDate() != null) {
            SET("update_date = #{updateDate,jdbcType=VARCHAR}");
        }
        if (record.getRemarks() != null) {
            SET("remarks = #{remarks,jdbcType=VARCHAR}");
        }
        if (record.getDelFlag() != null) {
            SET("del_flag = #{delFlag,jdbcType=VARCHAR}");
        }
        if (record.getName() != null) {
            SET("name = #{name,jdbcType=VARCHAR}");
        }
        if (record.getPhoto() != null) {
            SET("photo = #{photo,jdbcType=VARCHAR}");
        }
        if (record.getSex() != null) {
            SET("sex = #{sex,jdbcType=VARCHAR}");
        }
        if (record.getTgType() != null) {
            SET("tg_type = #{tgType,jdbcType=VARCHAR}");
        }
        if (record.getGrade() != null) {
            SET("grade = #{grade,jdbcType=VARCHAR}");
        }
        if (record.getYear() != null) {
            SET("year = #{year,jdbcType=VARCHAR}");
        }
        if (record.getState() != null) {
            SET("state = #{state,jdbcType=VARCHAR}");
        }
    }
}